kernel command line extension
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Jun 2007 15:52:01 +0000 (16:52 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Jun 2007 15:52:01 +0000 (16:52 +0100)
In order to allow appending to the dom0 command line even with boot
loaders that only allow editing the kernel (i.e. Xen in our case)
command line, support a '--' separator option.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/setup.c

index 23e216ac44e27a40885a2bda723ba7486e514f09..c630cb242fdc4a224cb2f4a6e822ec45b12974dc 100644 (file)
@@ -405,7 +405,7 @@ void init_done(void)
 void __init __start_xen(unsigned long mbi_p)
 {
     char *memmap_type = NULL;
-    char __cmdline[] = "", *cmdline = __cmdline;
+    char __cmdline[] = "", *cmdline = __cmdline, *kextra;
     unsigned long _initrd_start = 0, _initrd_len = 0;
     unsigned int initrdidx = 1;
     char *_policy_start = NULL;
@@ -426,6 +426,17 @@ void __init __start_xen(unsigned long mbi_p)
     /* Parse the command-line options. */
     if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
         cmdline = __va(mbi->cmdline);
+    if ( (kextra = strstr(cmdline, " -- ")) != NULL )
+    {
+        /*
+         * Options after ' -- ' separator belong to dom0.
+         *  1. Orphan dom0's options from Xen's command line.
+         *  2. Skip all but final leading space from dom0's options.
+         */
+        *kextra = '\0';
+        kextra += 3;
+        while ( kextra[1] == ' ' ) kextra++;
+    }
     cmdline_parse(cmdline);
 
     parse_video_info();
@@ -1009,18 +1020,27 @@ void __init __start_xen(unsigned long mbi_p)
 
     /* Grab the DOM0 command line. */
     cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
-    if ( cmdline != NULL )
+    if ( (cmdline != NULL) || (kextra != NULL) )
     {
         static char dom0_cmdline[MAX_GUEST_CMDLINE];
 
-        /* Skip past the image name and copy to a local buffer. */
-        while ( *cmdline == ' ' ) cmdline++;
-        if ( (cmdline = strchr(cmdline, ' ')) != NULL )
+        dom0_cmdline[0] = '\0';
+
+        if ( cmdline != NULL )
         {
+            /* Skip past the image name and copy to a local buffer. */
             while ( *cmdline == ' ' ) cmdline++;
-            safe_strcpy(dom0_cmdline, cmdline);
+            if ( (cmdline = strchr(cmdline, ' ')) != NULL )
+            {
+                while ( *cmdline == ' ' ) cmdline++;
+                safe_strcpy(dom0_cmdline, cmdline);
+            }
         }
 
+        if ( kextra != NULL )
+            /* kextra always includes exactly one leading space. */
+            safe_strcat(dom0_cmdline, kextra);
+
         /* Append any extra parameters. */
         if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") )
             safe_strcat(dom0_cmdline, " noapic");